package com.nipun.graph.display;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Event;
import java.awt.Frame;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.Scrollbar;

public class GraphDisplayWindow extends Frame {
	
	public GraphDisplayWindow(){
		super("Graph");
		setSize(500, 500);
		setLayout(new BorderLayout(50,50));
		MenuBar mb = new MenuBar();
		Menu file = new Menu("file");
		mb.add(file);
		setMenuBar(mb);
		add("South", new Button("close"));
		add("East", new Scrollbar());
	}
	
	public boolean action(Event evt, Object arg){
		System.out.println(evt.target +"--"+arg);
		if(evt.target instanceof Button){
			handleButtonClick(arg);
		}
		return true;
	}
	
	public boolean handleEvent(Event evt){
		if(evt.target instanceof Scrollbar){
			System.out.println(((Scrollbar)evt.target).getValue());
		}else if(evt.target instanceof Button){
			if(evt.arg!=null){
				handleButtonClick(evt.arg);
			}
		}
		return true;
	}
	
	private void handleButtonClick(Object arg){
		String act = arg.toString();
		if("close".equals(act)){
			this.hide();
		}
	}
	

}
